package dtd.PHS.VND_ExchangeRate.ui;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import dtd.PHS.VND_ExchangeRate.R;
import dtd.PHS.VND_ExchangeRate.R.string;
import dtd.PHS.VND_ExchangeRate.data.SJCItem;
import dtd.PHS.VND_ExchangeRate.utils.Helpers;

public class ShareGoldPriceDialog extends Dialog {

	private Activity activity;
	private SJCItem goldPrice;
	private ShareInfoDialogCreator creator;

	public ShareGoldPriceDialog(Activity activity) {
		super(activity);
		this.activity = activity;
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		creator = new ShareInfoDialogCreator(this);
		
		creator.setOnShareSMSClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				String content = Helpers.createSMSContent(goldPrice);
				Helpers.broadcastSMSIntent(content);
				cancel();
				
			}
		});
		
		creator.setOnShareEmailClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String content = Helpers.createSMSContent(goldPrice);
				Helpers.broadcastEmailIntent(activity,content);
				cancel();				
			}
		});
	}
	
	public void prepare(SJCItem price) {
		goldPrice = price;
		String SJCPrice= getContext().getString(R.string.SJC_price);
		creator.setTitle(SJCPrice + " ");
	}

}
